import tkinter as tk
from tkinter import messagebox
from tkinter import simpledialog


def show_message_box():
    # 创建消息框
    messagebox.showinfo("提示", "这是一个消息框！")


def show_input_dialog():
    # 创建输入框对话框
    result = simpledialog.askstring("输入框", "请输入一个字符串：")
    if result is not None:
        messagebox.showinfo("结果", f"你输入的字符串是：{result}")


# 创建主窗口
window = tk.Tk()

# 创建按钮
button1 = tk.Button(window, text="显示消息框", command=show_message_box)
button1.pack()

button2 = tk.Button(window, text="显示输入框对话框", command=show_input_dialog)
button2.pack()

# 启动主循环
window.mainloop()
